package io.renren.common.utils;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 自动填充类
 */
@Component
public class MybatisPlusMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("cretime",new Date(),metaObject);
        this.setFieldValByName("updtime",new Date(),metaObject);
        this.setFieldValByName("outStatus",ConfigConstant.OUTSTATUS_INITIAL,metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("updtime",new Date(),metaObject);
    }
}
